package com.cqndt.disaster.device.service.impl;

import java.util.List;
import com.cqndt.disaster.device.dao.*;
import com.cqndt.disaster.device.util.Result;
import org.springframework.stereotype.Service;
import com.cqndt.disaster.device.vo.TabDeviceVo;
import com.cqndt.disaster.device.vo.TabSensorVo;
import com.cqndt.disaster.device.domain.TabDevice;
import com.cqndt.disaster.device.domain.TabDeviceType;
import com.cqndt.disaster.device.domain.TabDeviceCheck;
import com.cqndt.disaster.device.service.TabDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.cqndt.disaster.device.domain.TabDeviceInstallWithBLOBs;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

@Service
public class TabDeviceServiceImpl extends ServiceImpl<TabDeviceMapper,TabDevice>
		implements TabDeviceService {
	
    @Autowired
    private TabDeviceMapper tabDeviceMapper;
    @Autowired
    private TabDeviceTypeMapper tabDeviceTypeMapper;
    @Autowired
    private TabSensorMapper tabSensorMapper;
    @Autowired
    private TabDeviceInstallMapper tabDeviceInstallMapper;
    @Autowired
    private TabDeviceCheckMapper tabDeviceCheckMapper;
    @Autowired
    private TabMonitorMapper tabMonitorMapper;
    @Override
    public List<TabDeviceVo> listTabDevice(TabDeviceVo vo){
        return tabDeviceMapper.listTabDevice(vo);
    }
    @Override
    public TabDeviceVo getTabDevice(Integer id,String reviceTime) {
        return tabDeviceMapper.getTabDevice(id,reviceTime);
    }
    @Override
    public TabDeviceInstallWithBLOBs selectInstallByDeviceNo(String deviceNo){
        return tabDeviceInstallMapper.selectInstallByDeviceNo(deviceNo);
    }
    @Override
    public List<TabSensorVo> getSensorByMonitorNo(String monitorNo){
        return tabSensorMapper.getSensorByMonitorNo(monitorNo);
    }
	@Override
	public Result selectDeviceType(Integer deviceType, String monitorNo) {
		List<TabDeviceType> tabDeviceTypes=tabDeviceTypeMapper.selectDeviceType1(deviceType,monitorNo);
        return new Result().success(tabDeviceTypes);
	}
	@Override
	@Transactional(readOnly=true)
    public List<TabDeviceCheck> selectByDeviceNo(String deviceNo){
        return tabDeviceCheckMapper.selectByDeviceNo(deviceNo);
    }
	@Override
	public Result selectType(String projectId) {
		List<String> sensorType = tabMonitorMapper.getSensorType();
        return new Result().success(sensorType);
	}
	@Override
    public Result selectSensorType() {
        List<String> sensorType = tabMonitorMapper.getSensorType();
        return new Result().success(sensorType);
    }
	@Override
    public Result updateScale(Integer typeId, String scale) {
//        TabDeviceType tabDeviceType = tabDeviceTypeMapper.selectDeviceType(deviceType,monitorNo,deviceTypeName);
//        if(tabDeviceType == null){
//            tabDeviceType = new TabDeviceType();
//            tabDeviceType.setDeviceType(deviceType);
//            tabDeviceType.setMonitorNo(monitorNo);
//            tabDeviceType.setType(deviceTypeName);
//            tabDeviceType.setAddTime(new Date());
//            tabDeviceType.setScale(scale);
//            return new Result().success(tabDeviceTypeMapper.insertScale(tabDeviceType));
//        }else {
//            tabDeviceType.setScale(scale);
        return new Result().success(tabDeviceTypeMapper.updateScale(typeId, scale));
    }
}